﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Windows.Forms;

namespace OWA
{
    public partial class LoginForm : Form
    {
        /// <summary>
        /// Display the login form
        /// </summary>
        public LoginForm()
        {
            InitializeComponent();

            cboVersion.Items.Clear();
            cboVersion.Items.Add("2003");
            cboVersion.Items.Add("2007");

            // Read data in registry
            txtUrl.Text = Configuration.Url;
            cboVersion.Text = Configuration.Version;
            txtLogin.Text = Configuration.Login;
            txtPassword.Text = Configuration.Password;
            chkModalForm.Checked = Configuration.ModalForm;
        }

        /// <summary>
        /// Save data in registry
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            // Write data in registry
            Configuration.Url = txtUrl.Text;
            Configuration.Version = cboVersion.Text;
            Configuration.Login = txtLogin.Text;
            Configuration.Password = txtPassword.Text;
            Configuration.ModalForm = chkModalForm.Checked;

            MessageBox.Show("You must restart this software to utilize new parameters.", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

        }
    }
}
